/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('cdt', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeRegionsRequest {
  acceptLanguage?: string(name='AcceptLanguage'),
}

model DescribeRegionsResponseBody = {
  regions?: [ 
    {
      localName?: string(name='LocalName'),
      regionId?: string(name='RegionId'),
    }
  ](name='Regions'),
  requestId?: string(name='RequestId'),
}

model DescribeRegionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeRegionsResponseBody(name='body'),
}

async function describeRegionsWithOptions(request: DescribeRegionsRequest, runtime: Util.RuntimeOptions): DescribeRegionsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.acceptLanguage)) {
    query['AcceptLanguage'] = request.acceptLanguage;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeRegions',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeRegions(request: DescribeRegionsRequest): DescribeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeRegionsWithOptions(request, runtime);
}

model GetCdtCbServiceStatusResponseBody = {
  enabled?: boolean(name='Enabled'),
  requestId?: string(name='RequestId'),
}

model GetCdtCbServiceStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetCdtCbServiceStatusResponseBody(name='body'),
}

async function getCdtCbServiceStatusWithOptions(runtime: Util.RuntimeOptions): GetCdtCbServiceStatusResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'GetCdtCbServiceStatus',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getCdtCbServiceStatus(): GetCdtCbServiceStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getCdtCbServiceStatusWithOptions(runtime);
}

model GetCdtInternetServiceStatusResponseBody = {
  enabled?: boolean(name='Enabled'),
  requestId?: string(name='RequestId'),
}

model GetCdtInternetServiceStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetCdtInternetServiceStatusResponseBody(name='body'),
}

async function getCdtInternetServiceStatusWithOptions(runtime: Util.RuntimeOptions): GetCdtInternetServiceStatusResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'GetCdtInternetServiceStatus',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getCdtInternetServiceStatus(): GetCdtInternetServiceStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getCdtInternetServiceStatusWithOptions(runtime);
}

model GetCdtServiceStatusResponseBody = {
  enabled?: boolean(name='Enabled'),
  requestId?: string(name='RequestId'),
}

model GetCdtServiceStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetCdtServiceStatusResponseBody(name='body'),
}

async function getCdtServiceStatusWithOptions(runtime: Util.RuntimeOptions): GetCdtServiceStatusResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'GetCdtServiceStatus',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getCdtServiceStatus(): GetCdtServiceStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getCdtServiceStatusWithOptions(runtime);
}

model ListCdtCrossBordTrafficRequest {
  businessRegionId?: string(name='BusinessRegionId'),
}

model ListCdtCrossBordTrafficResponseBody = {
  requestId?: string(name='RequestId'),
  trafficDetails?: [ 
    {
      businessRegionId?: string(name='BusinessRegionId'),
      productTrafficDetails?: [ 
        {
          product?: string(name='Product'),
          traffic?: long(name='Traffic'),
        }
      ](name='ProductTrafficDetails'),
      traffic?: long(name='Traffic'),
    }
  ](name='TrafficDetails'),
}

model ListCdtCrossBordTrafficResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListCdtCrossBordTrafficResponseBody(name='body'),
}

async function listCdtCrossBordTrafficWithOptions(request: ListCdtCrossBordTrafficRequest, runtime: Util.RuntimeOptions): ListCdtCrossBordTrafficResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListCdtCrossBordTraffic',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listCdtCrossBordTraffic(request: ListCdtCrossBordTrafficRequest): ListCdtCrossBordTrafficResponse {
  var runtime = new Util.RuntimeOptions{};
  return listCdtCrossBordTrafficWithOptions(request, runtime);
}

model ListCdtInternetTrafficRequest {
  businessRegionId?: string(name='BusinessRegionId'),
}

model ListCdtInternetTrafficResponseBody = {
  requestId?: string(name='RequestId'),
  trafficDetails?: [ 
    {
      businessRegionId?: string(name='BusinessRegionId'),
      ISPType?: string(name='ISPType'),
      productTrafficDetails?: [ 
        {
          product?: string(name='Product'),
          traffic?: long(name='Traffic'),
        }
      ](name='ProductTrafficDetails'),
      traffic?: long(name='Traffic'),
      trafficTierDetails?: [ 
        {
          highestTraffic?: long(name='HighestTraffic'),
          lowestTraffic?: long(name='LowestTraffic'),
          tier?: long(name='Tier'),
          traffic?: long(name='Traffic'),
        }
      ](name='TrafficTierDetails'),
    }
  ](name='TrafficDetails'),
}

model ListCdtInternetTrafficResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListCdtInternetTrafficResponseBody(name='body'),
}

async function listCdtInternetTrafficWithOptions(request: ListCdtInternetTrafficRequest, runtime: Util.RuntimeOptions): ListCdtInternetTrafficResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListCdtInternetTraffic',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listCdtInternetTraffic(request: ListCdtInternetTrafficRequest): ListCdtInternetTrafficResponse {
  var runtime = new Util.RuntimeOptions{};
  return listCdtInternetTrafficWithOptions(request, runtime);
}

model ListCdtProductsRequest {
  businessRegionId?: string(name='BusinessRegionId'),
  product?: string(name='Product'),
}

model ListCdtProductsResponseBody = {
  cdtProducts?: [ 
    {
      billingType?: string(name='BillingType'),
      businessRegionId?: string(name='BusinessRegionId'),
      cdtType?: string(name='CdtType'),
      effectiveTime?: long(name='EffectiveTime'),
      expireTime?: long(name='ExpireTime'),
      product?: string(name='Product'),
      switchedToCdt?: boolean(name='SwitchedToCdt'),
    }
  ](name='CdtProducts'),
  requestId?: string(name='RequestId'),
}

model ListCdtProductsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListCdtProductsResponseBody(name='body'),
}

async function listCdtProductsWithOptions(request: ListCdtProductsRequest, runtime: Util.RuntimeOptions): ListCdtProductsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListCdtProducts',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listCdtProducts(request: ListCdtProductsRequest): ListCdtProductsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listCdtProductsWithOptions(request, runtime);
}

model ListCdtTrafficTiersRequest {
  businessRegionId?: string(name='BusinessRegionId'),
}

model ListCdtTrafficTiersResponseBody = {
  requestId?: string(name='RequestId'),
  trafficTiers?: [ 
    {
      highestTraffic?: long(name='HighestTraffic'),
      lowestTraffic?: long(name='LowestTraffic'),
      tier?: long(name='Tier'),
    }
  ](name='TrafficTiers'),
}

model ListCdtTrafficTiersResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListCdtTrafficTiersResponseBody(name='body'),
}

async function listCdtTrafficTiersWithOptions(request: ListCdtTrafficTiersRequest, runtime: Util.RuntimeOptions): ListCdtTrafficTiersResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListCdtTrafficTiers',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listCdtTrafficTiers(request: ListCdtTrafficTiersRequest): ListCdtTrafficTiersResponse {
  var runtime = new Util.RuntimeOptions{};
  return listCdtTrafficTiersWithOptions(request, runtime);
}

model ListSwitchedCdtProductsRequest {
  businessRegionId?: string(name='BusinessRegionId'),
  product?: string(name='Product'),
}

model ListSwitchedCdtProductsResponseBody = {
  cdtProducts?: [ 
    {
      billingType?: string(name='BillingType'),
      businessRegionId?: string(name='BusinessRegionId'),
      cdtType?: string(name='CdtType'),
      effectiveTime?: long(name='EffectiveTime'),
      expireTime?: long(name='ExpireTime'),
      product?: string(name='Product'),
    }
  ](name='CdtProducts'),
  requestId?: string(name='RequestId'),
}

model ListSwitchedCdtProductsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListSwitchedCdtProductsResponseBody(name='body'),
}

async function listSwitchedCdtProductsWithOptions(request: ListSwitchedCdtProductsRequest, runtime: Util.RuntimeOptions): ListSwitchedCdtProductsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListSwitchedCdtProducts',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listSwitchedCdtProducts(request: ListSwitchedCdtProductsRequest): ListSwitchedCdtProductsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listSwitchedCdtProductsWithOptions(request, runtime);
}

model OpenCdtCbServiceResponseBody = {
  orderId?: string(name='OrderId'),
  requestId?: string(name='RequestId'),
}

model OpenCdtCbServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenCdtCbServiceResponseBody(name='body'),
}

async function openCdtCbServiceWithOptions(runtime: Util.RuntimeOptions): OpenCdtCbServiceResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'OpenCdtCbService',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function openCdtCbService(): OpenCdtCbServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return openCdtCbServiceWithOptions(runtime);
}

model OpenCdtInternetServiceResponseBody = {
  orderId?: long(name='OrderId'),
  requestId?: string(name='RequestId'),
}

model OpenCdtInternetServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenCdtInternetServiceResponseBody(name='body'),
}

async function openCdtInternetServiceWithOptions(runtime: Util.RuntimeOptions): OpenCdtInternetServiceResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'OpenCdtInternetService',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function openCdtInternetService(): OpenCdtInternetServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return openCdtInternetServiceWithOptions(runtime);
}

model OpenCdtServiceResponseBody = {
  orderId?: string(name='OrderId', example='******'),
  requestId?: string(name='RequestId', example='FF39F653-033E-4CD9-9EDF-3CCA5A71FBC3'),
}

model OpenCdtServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: OpenCdtServiceResponseBody(name='body'),
}

async function openCdtServiceWithOptions(runtime: Util.RuntimeOptions): OpenCdtServiceResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'OpenCdtService',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function openCdtService(): OpenCdtServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return openCdtServiceWithOptions(runtime);
}

model SwitchToCdtRequest {
  billingType?: string(name='BillingType'),
  businessRegionId?: string(name='BusinessRegionId'),
  product?: string(name='Product'),
}

model SwitchToCdtResponseBody = {
  effectiveTime?: long(name='EffectiveTime'),
  requestId?: string(name='RequestId'),
}

model SwitchToCdtResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SwitchToCdtResponseBody(name='body'),
}

async function switchToCdtWithOptions(request: SwitchToCdtRequest, runtime: Util.RuntimeOptions): SwitchToCdtResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.billingType)) {
    query['BillingType'] = request.billingType;
  }
  if (!Util.isUnset(request.businessRegionId)) {
    query['BusinessRegionId'] = request.businessRegionId;
  }
  if (!Util.isUnset(request.product)) {
    query['Product'] = request.product;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SwitchToCdt',
    version = '2021-08-13',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function switchToCdt(request: SwitchToCdtRequest): SwitchToCdtResponse {
  var runtime = new Util.RuntimeOptions{};
  return switchToCdtWithOptions(request, runtime);
}

